import request from "@/axios"

//获取地址列表
export function listAddress() {
    let url = '/api/order/address'
    return request.get(url)
}

//更新地址
export function mergeAddress(address) {
    let url = '/api/order/address'
    let data = address
    data.Loading = true
    return request.post(url, data)
}

//获取地址
export function getAddress(id) {
    let url = '/api/order/address/info'
    let params = {id}
    return request.get(url, {params})
}

//移除地址
export function removeAddress(id) {
    let url = '/api/order/address/remove'
    let params = {id}
    return request.get(url, {params})
}

//提交订单
export function commitOrder(address) {
    let url = '/api/order/cart/commit'
    let data = address
    data.Loading = true
    return request.post(url, data)

}

//查询订单
export function listOrder(page) {
    let url = '/api/order/list'
    let limit = 10
    let params = {page, limit}
    return request.get(url, {params})
}

//获取订单
export function getOrder(id, orderNo) {
    let url = '/api/order/info'
    let params = {id, orderNo}
    return request.get(url, {params})
}

//移除订单
export function removeOrder(orderId) {
    let url = '/api/order/remove'
    let data = {
        orderId,
        Loading: true
    }
    return request.post(url, data)
}

//统一下单
export function unionPay(orderNo) {
    let url = '/api/order/wx/union'
    let data = {orderNo}
    data.Loading = true
    return request.post(url, data)
}

//查询货物状态
export function searchReceived() {
    let url = '/api/order/findOrdersByStatus?status=2'

    return request.get(url)
}

//确认收货
export function sureReceipt(orderNo) {
    let url = '/api/order/sureReceipt'
    let params = {
        orderNo,
        Loading: true
    }
    return request.post(url, params)
}

export function getLogistics(no) {
    let url=`api/logistics/find?no=${no}`
    return request.get(url)
}

export function getWithdrawList(page) {
    let url = `/api/cashApply/list?page=${page}&limit=15`
    return request.get(url)
}

export function getBankList() {
    let url = '/api/accCard/accList'
    return request.get(url)
}

export function saveBankCard(accName,bank,accBranch,number) {
    let url = '/api/accCard/save'
    let params ={
        accName,
        bank,
        accBranch,
        number
    }
    return request.get(url, {params})
}

export function deleteBankCard(id) {
    let url=`/api/accCard/delete?id=${id}`
    return request.get(url)
}

export function editBankCard(id,accName,bank,accBranch,number) {
    let url = '/api/accCard/update'
    let params ={
        id,
        accName,
        bank,
        accBranch,
        number
    }
    return request.get(url, {params})
}

export function getOrderByOrderNo(orderNo) {
    let url = `api/order/info?orderNo=${orderNo}`

    return request.get(url)
}
